package info.liuxing.config;

import info.liuxing.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;


// 配置类 == 配置文件xml，该注解用于声明这是一个配置类
@Configuration
@ComponentScan(value = "info.liuxing")

// 配置只包含controller
//@ComponentScan(value = "info.liuxing",
//        includeFilters = {
//                @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class})
//        },
//        useDefaultFilters = false
//)

//Jdk8 可以支持重复的注解@ComponentScan 来支持多个扫描定义
//非Jdk8 可以指定@ComponentScans 来支持多个扫描定义
public class MainConfig {

    // 默认使用方法名作为id，也可以在Bean注解中指定
    @Bean(name = "person")
    public Person person() {
        return new Person("test", 1);
    }

}
